package com.cskaoyan.controller.wx.zjh;

import com.cskaoyan.module.bean.BaseRespVo;
import com.cskaoyan.module.pojo.MarketUser;
import com.cskaoyan.service.wx.zjh.BrandAndCatalogService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Description:
 * @Author: 周佳豪
 * @Date: 2022/04/11/13:55
 */
@RestController
@RequestMapping("wx")
public class BrandAndCatalogController {
    @Autowired
    BrandAndCatalogService brandAndCatalogService;

    @GetMapping("catalog/current")
    public BaseRespVo catalogCurrent(Integer id) {
        BaseRespVo baseRespVo = brandAndCatalogService.catalogCurrent(id);
        return baseRespVo;
    }

    @GetMapping("catalog/index")
    public BaseRespVo catalogIndex() {
        BaseRespVo baseRespVo = brandAndCatalogService.catalogIndex();
        return baseRespVo;
    }

    @GetMapping("brand/detail")
    public BaseRespVo brandDetail(Integer id) {
        BaseRespVo baseRespVo = brandAndCatalogService.brandDetail(id);
        return baseRespVo;
    }

    @GetMapping("brand/list")
    public BaseRespVo brandList(Integer page,Integer limit) {
        BaseRespVo baseRespVo = brandAndCatalogService.brandList(page,limit);
        return baseRespVo;
    }


    @GetMapping("user/index")
    public BaseRespVo userIndex() {
        Subject subject = SecurityUtils.getSubject();
        MarketUser marketUser = (MarketUser) subject.getPrincipals().getPrimaryPrincipal();

        Integer id = marketUser.getId();

        BaseRespVo baseRespVo = brandAndCatalogService.userIndex(id);
        return baseRespVo;
    }
}
